<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="../include/taglib.jsp"%>
<%@ page import = "java.util.*" %>
<%@ page import = "com.sinodata.bsm.common.vo.Probe" %>
<%@ page import = "com.sinodata.bsm.common.constants.RelationConstants" %>
<%@page import="com.sinodata.bsm.center.user.UserUtil"%>
<%@page import="com.sinodata.bsm.center.purview.FunctionConstants"%>
<%@page import="com.sinodata.bsm.center.purview.UserFunctionValidate"%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>集成网络资源</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="pragma" content="no-cache"/>
	<meta http-equiv="cache-control" content="no-cache"/>
	<meta http-equiv="expires" content="0"/>  
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/table.jsp"%>
	<%@ include file="../include/jbox.jsp"%>
		<link href="${pageContext.request.contextPath}/style/default/form/ui.tabs.css" type="text/css" rel="stylesheet" media="print, projection, screen"/>
 
	<link rel="stylesheet" type="text/css"
	    href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />
	   
	 <link rel="stylesheet" type="text/css"
	      href="${pageContext.request.contextPath}/style/default/select/jquery.image.select.css" />
	 <script type="text/javascript"
	      src="${pageContext.request.contextPath}/js/select/jquery.image.select.min.js"></script>
	  
	<style>
		.tip{
			border:1px dotted blue;
			height:20px;
			display: block;
			font-weight:blod;
		}
	
	</style>
	<script type="text/javascript">
	function datagrid(){
		var oTable=	$('#findList').dataTable();
		oTable.fnPageChange("first",true);
	}
		$(document).ready(function(){
			$("#probeId").msDropDown().data("dd");
			var oTable=	$('#findList').dataTable({
				"bProcessing": false, 
				"bServerSide": true,
				"sServerMethod": 'POST',
				"sAjaxSource":'${pageContext.request.contextPath}/integration/inmp!getNodeList.action',
				"bPaginate": false,
				"bSort": true,
				"bFilter":false,
				"sDom":'rt <"bottom"flpi>',
				"bJQueryUI":false,
				 "fnServerParams":function(aoData){
					 aoData.push({'name':'probeId','value':$('#probeId').find('option:selected').val()});
					 aoData.push({'name':'flag','value':$('#flag').val()});
					 aoData.push({'name':'viewId','value':${viewId}});
				 },
				"aoColumns":[
					{"mDataProp":"probeName","bSortable": false},
					{"mDataProp":"resName","bSortable": false},
					{"mDataProp":"ip","bSortable": false},
					{"mDataProp":"resTypeName","bSortable": false},
					{"mDataProp":"change","bSortable": false}
				], 
				 "oLanguage": { 
					 "sInfo": "共 _TOTAL_ 条记录",
					 "sInfoEmpty": "没有找到记录",
					 "sZeroRecords": "没有找到记录"
				}
			});
			$('#find').click(function(){
				if($('#probeId').find('option:selected').val() == ''){
					getTopWin(window).getMessageBox().alert("请先选择probe","提示");
					return;
				}
				if($('#parent').val()==''){
					getTopWin(window).getMessageBox().alert("请先选择父资源","提示");
					return;
				}
				$('#flag').val('0');
				datagrid();
				$('#save').css('display','');
			});
			
			
			
			$('#save').click(function(){
				getTopWin(window).getMessageBox().tip('发现并确认过程中,请稍候...', 'loading');
				$('#save').css('display','none');
				$.ajax({
					url : 'inmp!add.action', 
					type : 'POST',
					dataType : "json",
					data : {
						probeId:$('#probeId').find('option:selected').val(),
						viewId:'${viewId}',
						parentId:$('#parent').val()
					},
					success : function(data) {
						if(data.flag=='success'){
							getTopWin(window).getMessageBox().tip('发现并确认成功!', 'success',{timeout: 2000});
							window.parent.parent.refreshTree();
							$('#flag').val('1');
							datagrid();
						}else{
							getTopWin(window).getMessageBox().closeTip();
							getTopWin(window).getMessageBox().alert("发现并确认过程中出现错误，请刷新页面后重新获取资源列表并发现确认！","提示");
							$('#flag').val('1');
							window.parent.parent.refreshTree();
							datagrid();
						}
					}
				});
			});
		});
		
	</script>
	
  </head>
  <body style="width:99%">
  		<ul class="ui-tabs-nav">
			<li ><a href="../resource/res!guide.action?id=${id}&viewId=${viewId}&ntype=${ntype}" target="_self" style="text-decoration:none;"><span>新增单个资源</span></a></li> 
			<li><a href="../integration/tivoli!guide.action?id=${id}&viewId=${viewId}&ntype=${ntype}" target="_self" style="text-decoration:none;"><span>集成TIVOLI资源</span></a></li>
			<li class="ui-tabs-selected"><a href="../integration/inmp!guide.action?id=${id}&viewId=${viewId}&ntype=${ntype}" style="text-decoration:none;"><span>集成朗易资源</span></a></li>
			<li><a href="../integration/inmpop!guide.action?id=${id}&viewId=${viewId}&ntype=${ntype}" style="text-decoration:none;"><span>集成ZOHO资源</span></a></li>
			<li><a href="../resource/res-type!resImport.action?resId=${id}&viewId=${viewId}&ntype=${ntype}" style="text-decoration:none;"><span>导入资源</span></a></li> 
		</ul> 
		<div class="ui-tabs-panel"/>
    <table class="table_eidt" id="restable" >
		<tbody>
	    	<tr>
	    		<td class="td_left" style="width:100px;">
					<span class="span_alert">*</span> 采集器
				</td>
	    		<td class="td_right" style="width:auto;">
	    				<select id="probeId" name = "probeId"  class = "select" style="width:250px;">
	    				 <option value="" title=''>---- 请选择采集器 ----</option>
	    					<%
	    						List<Probe> probes = (List<Probe>)request.getAttribute("probeList");
	    						for(Probe  p : probes){
	    						    if(p.getStatus()==3){
	    			    				out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/proberun.png' >"+p.getId()+"_"+p.getName()+"</option>");
	    						    }else{
	  	    			    			out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/probestop.png' >"+p.getId()+"_"+p.getName()+"</option>");
	    						    }
	    						}
	    					%>
	    				</select>
	    			&nbsp;&nbsp;
	    			<button class="btn-4" id="find">
						获取资源列表
					</button>
					
	    			&nbsp;&nbsp;
	    			
	    			<button class="btn-4" id="save" style="display:none;">
						发现并确认
					</button>
				</td>
	    	</tr>
		</tbody>
    </table>
    
    
    <input type="hidden" id="flag" name="flag" value="0">
    <input type="hidden" id="parent" name="flag" value="${id }"></input>
    <h2 class="title-h2"><span>资源列表</span></h2>
	    <table id="findList" width="100%" cellpadding="0" cellspacing="0" border="0" class="display">
			<thead>
				<tr>
					<th width="10%">采集器</th>
					<th width="15%">资源名称</th>
					<th width="10%">资源IP</th>
					<th width="15%">资源类别</th>
					<th width="50%">变化情况</th>
				</tr>
			</thead>
		</table>
  </body>
</html>
